package com.xxx.modules.controller;;
import com.xxx.modules.service.MornService;
import com.xxx.modules.entity.Morn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * morn
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@RestController
@RequestMapping("/common/morn")
@Api(tags="morn")
public class MornController {
    @Autowired
    private MornService mornService;

    /**
    *  获取所有晨检信息
    * @param pageNum
    * @param pageSize
    * @param morn
    * @return
    */

    @GetMapping("/getMornInfo")
    @ApiOperation("获取所有晨检信息")
    public Result getMornInfo(Morn morn, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Morn> data = mornService.selectMornInfo(morn,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存晨检信息
    * @param morn
    * @return
    */
    @PostMapping("/saveMornInfo")
    @ApiOperation("保存晨检信息")
    public Result saveMornInfo(@RequestBody Morn morn){
        mornService.saveMornInfo(morn);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新晨检信息
     * @param morn
     * @return
     */

    @PutMapping("/updateMornInfo")
    @ApiOperation("更新晨检信息")
    public Result updateMornInfo(@RequestBody Morn morn){
        mornService.updateMornInfo(morn);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除晨检信息
     * @param id
     * @return
     */
    @DeleteMapping("/delMornInfo")
    @ApiOperation("根据id删除晨检信息")
    public Result delMornInfo(Integer id){
        mornService.delMornInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除晨检信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchMornInfo")
    @ApiOperation("根据id集合批量删除晨检信息")
    public Result delBatchMornInfo(String idList){
        mornService.delBatchMornInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}